/**
 * Copyright (c) 2018-2022, NXOS Development Team
 * SPDX-License-Identifier: Apache-2.0
 * 
 * Contains: stack backtrace
 * 
 * Change Logs:
 * Date           Author            Notes
 * 2022-07-28     JasonHu           Init
 */

#include <base/backtrace.h>
#define NX_LOG_NAME "backtrace"
#include <base/log.h>

NX_Error NX_StackBacktracePrint(void ** buffer, NX_Size size)
{
    int i;

    if (!buffer || !size)
    {
        return NX_EINVAL;
    }

    NX_LOG_I("---> Stack backtrace buffer %p size %d, recently call:", buffer, size);
    for (i = 0; i < size; i++)
    {
        NX_LOG_I("    [%d] call addr %p", i, buffer[i]);
    }

    return NX_EOK;
}
